package com.voxel.sense.infomsg.module.common.dropmenu.converstrategy;

import com.voxel.sense.infomsg.data.bean.ConditionBean;
import com.voxel.sense.infomsg.utils.cover.BaseCoverStrategy;

import java.util.ArrayList;
import java.util.List;

import cyy.example.com.facotry.constants.CommonConstants;
import cyy.example.com.facotry.constants.Constants;
import cyy.example.com.facotry.model.api.response.SearchMenuEntity;

/**
 * Created by ChenYiYao on 2018/9/7. 监管类型
 */
public class SuperviseStrategyImpl implements BaseCoverStrategy<ConditionBean,SearchMenuEntity> {
    @Override
    public List<ConditionBean> convertEntity(SearchMenuEntity entity, String type) {
        List<ConditionBean> datas = new ArrayList<>();
        if (entity == null || entity.getStaticSystemConstantDetails() == null ||
                entity.getStaticSystemConstantDetails().size() <= 0) {
            return datas;
        }
        List<SearchMenuEntity.StaticSystemConstantDetailsBean> conditions = entity.getStaticSystemConstantDetails();
        for (SearchMenuEntity.StaticSystemConstantDetailsBean bean : conditions) {
            String icon = "";
            if (Constants.TYPE_LEVEL.equals(type)) {
                icon = CommonConstants.FILE_CONFIG_URL + bean.getConstantName() + ".JPG";
            } else if (Constants.TYPE_NATURE.equals(type)) {
                icon = CommonConstants.FILE_CONFIG_URL + bean.getConstantName() + ".png";
            }
            ConditionBean conditionBean = new ConditionBean(type, bean.getConstantCode(),
                    bean.getConstantName(), icon, false);
            datas.add(conditionBean);
        }
        return datas;
    }
}
